const db = require('../db');
const { hashPassword } = require('../utils/passwordUtils');

async function updateAdminPassword() {
    try {
        // 生成加密密码
        const hashedPassword = await hashPassword('123456');
        
        // 更新数据库中的密码
        await db.promise().execute(
            'UPDATE admin SET password = ? WHERE username = ?',
            [hashedPassword, 'admin']
        );
        
        console.log('管理员密码更新成功');
        process.exit(0);
    } catch (error) {
        console.error('更新密码失败:', error);
        process.exit(1);
    }
}

updateAdminPassword(); 